import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import axios from 'axios'
import * as ElementPlusIconsVue from '@element-plus/icons-vue';

const app = createApp(App);
axios.defaults.baseURL = "http://192.168.50.8:10005"
axios.interceptors.request.use(req=> {
  if(localStorage.getItem("token")){
    req.headers['token'] = localStorage.getItem("token")
  }
  return req;
});
axios.interceptors.response.use(resp=>{
  if(resp.headers.token){
    localStorage.setItem("token", resp.headers.token);
  }
  return resp;
})
// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

app.use(router).use(ElementPlus).mount('#app');
